package testview.zhen.com.myapplication.hencoder.practice_draw1

import android.content.Context
import android.graphics.Canvas
import android.graphics.Paint
import android.os.Build
import androidx.annotation.RequiresApi
import android.util.AttributeSet
import android.view.View

class Practice8DrawArcView : View {

    constructor(context: Context) : super(context) {}

    constructor(context: Context, attrs: AttributeSet?) : super(context, attrs) {}

    constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {}

    @RequiresApi(Build.VERSION_CODES.LOLLIPOP)
    //给定的大小中获取部分为
    override fun onDraw(canvas: Canvas) {
        super.onDraw(canvas)
        var paint:Paint = Paint()
    //(float left, float top, float right, float bottom, float startAngle,float sweepAngle, boolean useCenter, @NonNull Paint paint
        canvas.drawArc(100.0f,100.0f,(canvas.width-100).toFloat(),canvas.height.toFloat(),-10.0f,-90.0f,true,paint)
        paint.style = Paint.Style.STROKE
        canvas.drawArc(100.0f,100.0f,(canvas.width-100).toFloat(),canvas.height.toFloat(),-110.0f,-60.0f,false,paint)
        paint.style = Paint.Style.FILL
        canvas.drawArc(100.0f,100.0f,(canvas.width-100).toFloat(),canvas.height.toFloat(),-180.0f,-180.0f,true,paint)






        //练习内容：使用 canvas.drawArc() 方法画弧形和扇形
    }
}
